package com.lty.jeeg.server.modules.fas.dao;

import java.util.List;
import java.util.Map;

import com.lty.jeeg.server.modules.fas.dto.HandOverDTO;
import com.lty.jeeg.server.modules.fas.export.HandOverExportEntity;
import com.lty.jeeg.server.modules.fas.vo.HandOverVO;
import org.apache.ibatis.annotations.*;

import org.springframework.stereotype.Repository;

import com.lty.jeeg.server.modules.fas.model.HandOver;

/**
 * @author : zl
 * @date : 2019-02-13 14:56:11
 * Description : 调拨记录
 */
@Mapper
@Repository
public interface HandOverDao {

    /**
     * 根据ID获取
     * @param id ID
     * @return bean
     */
    @Select("select * from fas_hand_over t where t.id = #{id}")
    HandOver getById(Long id);

    /**
     * 删除
     * @param id ID
     * @return 1/0
     */
    @Delete("delete from fas_hand_over where id = #{id}")
    int delete(Long id);

    /**
     * 修改
     * @param handOver ID
     * @return 1/0
     */
    int update(HandOver handOver);

    /**
     * 修改报废或置换的信息
     * @param handOver ID
     * @return 1/0
     */
    int updateDis(HandOver handOver);

    /**
     * 保存
     * @param handOver bean
     * @return ID
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into fas_hand_over(handlerId, handlerName, handleType, deployComeId, deployComeName, deployForId, deployForName, deployForpeoId, deployForpeoName, createBy, updateBy, remark, isDeleted, detailSpec, detailUnit, goodsId, goodsName, detailNum, unitPrice, totalPrice) values(#{handlerId}, #{handlerName}, #{handleType}, #{deployComeId}, #{deployComeName}, #{deployForId}, #{deployForName}, #{deployForpeoId}, #{deployForpeoName}, #{createBy}, #{updateBy}, #{remark}, #{isDeleted}, #{detailSpec}, #{detailUnit}, #{goodsId}, #{goodsName}, #{detailNum}, #{unitPrice}, #{totalPrice})")
    Long save(HandOver handOver);

    /**
     * 计数
     * @param params 筛选条件
     * @return 总数
     */
    int count(@Param("params") Map<String, Object> params);

    /**
     * 列表
     * @param params 筛选条件
     * @param offset 页码
     * @param limit 分页数目
     * @return beanList
     */
    List<HandOverVO> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    /**
     * 出入库记录数据(用于导出)
     * @param handOverDTO
     * @return
     */
    List<HandOverExportEntity> getExportDatas(HandOverDTO handOverDTO);

    @Update("UPDATE fas_hand_over t SET t.discardType=#{status} WHERE t.id=#{id}")
    @ResultType(int.class)
    int changeStatus(@Param("id")Long id,@Param("status")Integer status);
}
